import React from 'react';
import classNames from 'classnames';
import Input from './Input';
import Icon from '../Icon';


export default class Search extends React.Component {
  static defaultProps = {
    prefixCls: 'ant-input-search',
    onSearch() {},
  };

  render() {
    const { className, prefixCls, ...others } = this.props;
    delete others.onSearch;
    const searchSuffix = (
      <Icon
        className={`${prefixCls}-icon`}
        onClick={this.onSearch}
        type="search"
      />
    );
    return (
      <Input
        className={classNames(prefixCls, className)}
        ref={node => this.input = node}
        suffix={searchSuffix}
        {...others}
      />
    );
  }
}
